<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/backstage/cl/common/wechatLibs.jsp"%>
<!doctype html>
<html>
<head>
<title>登录</title>
<meta charset="utf-8">
<meta name="viewport"
	content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
<meta name="format-detection"
	content="telephone=no,email=no,date=no,address=no">

</head>
<body>
	<div class="loginbox">
		<divi class="login-logo"> <img
			src="/bsc/js/wechat/images/logo.png"> </divi>
		<div class="login-input">
			<div class="input-text">
				<i class="ico-phone"></i><input type="text" id="mobile"
					name="mobiel" placeholder="请输入手机号码">
			</div>
			<div class="input-text">
				<i class="ico-password"></i><input class="code" id="password"
					name="password" type="password" placeholder="请输入密码">
			</div>
			<input type="button" onclick="login()" value="登录">
			<input type="button" onclick="enroll()" value="注册">
		</div>
		<div class="login-text">
			登录即同意<span> <a class="wechat"
				href="/bsc/wechat/GoserverDeal">《美研社用户协议》</a></span>
		</div>
		<div class="login-b">
			<div class="login-b-tit">
				<span class="hr-rg"></span>
				<p>微信登录</p>
				<span class="hr-fl"></span>
			</div>
			<div class="login-b-ico">
			<!--<a class="wechat" href="${ctx}/pay.jsp">  -->
		<a class="wechat" href="/bsc/wechat/wechatLogin"><img
					src="/bsc/js/wechat/images/ico-wechat.png"></a>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	var mobileReg = /^1[2|3|4|5|7|8|9]\d{9}$/;

	var toast = new auiToast();
	function login() {
		var mobile = $("#mobile").val();
		var password = $("#password").val();
		if (mobile == '') {
			toast.fail({
				title : "请输入手机号码",
				duration : 2000
			});
			return;
		}
		if (password == '') {
			toast.fail({
				title : "请输入密码",
				duration : 2000
			});
			return;
		}
		if (!mobileReg.test(mobile)) { //验证手机号码
			toast.fail({
				title : "输入手机号码不合法",
				duration : 2000
			});
			return;
		}
		
		$.ajax({
			type : 'post',
			url : '/bsc/wechat/vaildate',
			data : {
				mobile:mobile,
				password:password
			},
			dataType : 'json',
			success : function(data) {
				if (data=='1') {
					toast.success({
						title : "登陆成功",
						duration : 2000
					});
					window.location.href = '/bsc/wechat/findProject';
				} else {
					toast.fail({
						title : "账号密码有误，请注册",
						duration : 3000
					});
				}
			},
			error : function() {
				toast.fail({
					title : "登陆失败，网络异常",
					duration : 2000
				});
			}
		})
	}
	
	function enroll(){
		window.location.href = '/bsc/wechat/enroll';
	}
</script>
</html>